package org.aplikator.client.shared.descriptor;

import org.aplikator.client.local.widgets.HasFields;
import org.aplikator.client.local.widgets.TextAreaWidget;

import com.google.gwt.user.client.ui.Widget;
import org.jboss.errai.common.client.api.annotations.Portable;

@SuppressWarnings("serial")
//@JsonTypeName("textarea")
//@Portable
public class TextAreaDTO extends WidgetPropertyDTOBase implements RenderWidgetAware {

	public static final String TYPE_KEY = "textarea";

    private int rows;

    @SuppressWarnings("unused")
    public TextAreaDTO() {//TODO custom marshaller
    }

    public TextAreaDTO(PropertyDTO property) {
        super(property);
        //this.rows=rows;
    }

    @Override
    public Widget getWidget(HasFields form) {
        TextAreaWidget field = new TextAreaWidget(property.getLocalizedName(), property, getSize(), rows);
        field.setEnabled(isEnabled());
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }

    public void setRows(int height) {
        this.rows = height;
    }

    public int getRows() {
        return rows;
    }

}
